#pragma once

#include <QSettings>
#include <QFont>
#include <QFontDialog>
#include <QApplication>

extern void saveQFont(QSettings &settings, const QFont &font, const QString &group = QString()) {
    QString fontGroup = group.isEmpty() ? "Font" : group + "/Font";
    settings.beginGroup(fontGroup);
    settings.setValue("Family", font.family());
    settings.setValue("PointSize", font.pointSize());
    settings.setValue("Bold", font.bold());
    settings.setValue("Italic", font.italic());
    settings.setValue("Underline", font.underline());
    settings.setValue("StrikeOut", font.strikeOut());
    settings.endGroup();
}

extern QFont loadQFont(QSettings &settings, const QString &group = QString()) {
    QString fontGroup = group.isEmpty() ? "Font" : group + "/Font";
    settings.beginGroup(fontGroup);
    QFont font;
    font.setFamily(settings.value("Family").toString());
    font.setPointSize(settings.value("PointSize").toInt());
    font.setBold(settings.value("Bold").toBool());
    font.setItalic(settings.value("Italic").toBool());
    font.setUnderline(settings.value("Underline").toBool());
    font.setStrikeOut(settings.value("StrikeOut").toBool());
    settings.endGroup();
    return font;
}
